from Crypto.Cipher import DES

string1 = '个人身份信息abc123'
obj_ECB = DES.new('abcd1234'.encode(),DES.MODE_ECB)   # 加密对象，调用encrypt和decrypt 实现加密和解密
obj_CBC = DES.new('abcd1234'.encode(),DES.MODE_CBC, iv='qwer1234'.encode())   # 加密秘钥'abcd1234'
ECB_res = obj_ECB.encrypt(string1.encode())
CBC_res = obj_CBC.encrypt(string1.encode())
print(ECB_res)
print(CBC_res)
print(string1.encode())

print(obj_ECB.decrypt(ECB_res).decode())    # 解密
